import React, {Component} from 'react';
import {StyleSheet, Text, View, Image, 
  TouchableOpacity,TextInput
} from 'react-native';
import Toast, {DURATION} from 'react-native-easy-toast'
import SplitView from './SplitView'
import BackButton from '../../component/BackButton';
import MyButton from '../../component/MyButton';
import DeviceStorage from '../../common/DeviceStorage';
import {jumpPage} from '../../common/common';
const dismissKeyboard = require('dismissKeyboard');
import {BASEURL} from '../../api/api'
export default class Setting extends Component{
  static navigationOptions = ({ navigation }) =>{
    return{
      title:'设置',
      headerRight:(<View></View>),
      headerLeft:<BackButton navigation = {navigation}/>
    }
  };
  constructor(props){
    super(props);
    this.state = ({
      
    })
  }
  _press(page){
    jumpPage(this.props.navigation,page);
  }

  _exit(){
    const {navigation} = this.props;
    //navigation.popToTop();
    //navigation.reset();
    if(navigation){
      DeviceStorage.delete('user');
      navigation.popToTop();
      //navigation.navigate('login');
      navigation.push('login');
    }
  }
  render(){
    return(
      <View style={{flex:1}}>
        <SplitView/>
        <TouchView text='账号安全' hasBorder={true} press={()=>this._press('accountSafe')}/>
        
        <TouchView text='推送设置' hasBorder={true}/>
				<TouchView text='新手指引' hasBorder={true} press={()=>this._press('newhandGuide')}/>
				<TouchView text='意见反馈'  press={()=>this._press('feedBack')}/>
				<SplitView/>
				<TouchView text='关于我们' ao={0.5} press={()=>this._press('aboutUs')}/>
        <View style={{flex:1,backgroundColor:'#f0f0f0'}}>
          <View style={{flex:1}}></View>
          <MyButton text='退出登录' btnStyle={{marginBottom:20}} press={()=>this._exit()}/>
        </View>
      </View>
    )
  }
}

class TouchView extends Component{
	render(){
		return(
			<TouchableOpacity activeOpacity={this.props.ao?this.props.ao:0.6}   style={{flexDirection:'row',justifyContent:'space-between',
      alignItems:'center',marginLeft:15,marginRight:15,paddingTop:10,paddingBottom:10,
      borderColor:'#ccc',borderBottomWidth:this.props.hasBorder?StyleSheet.hairlineWidth:0}}
			 onPress={this.props.press}> 
				<View style={{flexDirection:'row',alignItems:'center'}}>
					<Text style={{color:'#444',fontSize:16}}>{this.props.text}</Text>
				</View>
				<View style={{flexDirection:'row',alignItems:'center'}}>
					<Image style={{width:18,height:16}} source={require('../../images/mine/arrow_right.png')}/>
				</View>
				
			</TouchableOpacity>
		)
	}
}
const styles = StyleSheet.create({

})